Always defer the log publish() in recordUpload2
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 7 Nov 2015 00:15:34 +0000 (16:15 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 7 Nov 2015 00:15:34 +0000 (16:15 -0800)
This is more performant and simplifies the code a bit.

Change-Id: I7a30e000ae4eff47519b83eb6bdde57eeb8a18f6

includes/filerepo/file/LocalFile.php

index cd64f0d..12d4007 100644 (file)
@@ -1365,8 +1365,6 @@ class LocalFile extends File {
                $logId = $logEntry->insert();
 
                if ( $descTitle->exists() ) {
-                       // Page exists, do RC entry now (otherwise we wait for later)
-                       $logEntry->publish( $logId );
                        // Use own context to get the action text in content language
                        $formatter = LogFormatter::newFromEntry( $logEntry );
                        $formatter->setContext( RequestContext::newExtraneousContext( $descTitle ) );
@@ -1407,6 +1405,8 @@ class LocalFile extends File {
                ) {
                        # Update memcache after the commit
                        $that->invalidateCache();
+                       # Page exists, do RC entry now (otherwise we wait for later)
+                       $logEntry->publish( $logId );
 
                        if ( $newPageContent ) {
                                # New file page; create the description page.
@@ -1423,7 +1423,6 @@ class LocalFile extends File {
                                // Now that the page exists, make an RC entry.
                                // This relies on the resetArticleID() call in WikiPage::insertOn(),
                                // which is triggered on $descTitle by doEditContent() above.
-                               $logEntry->publish( $logId );
                                if ( isset( $status->value['revision'] ) ) {
                                        /** @var $rev Revision */
                                        $rev = $status->value['revision'];